// TaskMapper.java
package com.example.demo.mapper;

import com.example.demo.entity.Task;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TaskMapper {
    // 根据课程ID查询所有任务
    @Select("SELECT * FROM tasks WHERE course_id = #{courseId} ORDER BY created_at DESC")
    List<Task> findByCourseId(@Param("courseId") String courseId);

    // 根据任务ID查询任务
    @Select("SELECT * FROM tasks WHERE task_id = #{taskId}")
    Task findById(@Param("taskId") Long taskId);
}